package com.hengxing.controller;


import com.hengxing.domain.Book;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/book")
public class BookController {
    @PostMapping("/books")
    public String save(@RequestBody Book book) {
        System.out.println("save book...." + book);
        return "{save book success....}";
    }

    @GetMapping("/books")
    public List<Book> getAll() {
        List<Book> listBook = new ArrayList<>();
        Book book1 = new Book();
        book1.setName("springmvc入门测试");
        book1.setType("JAVA");
        book1.setDesciption("springmvc入门测试开始");

        Book book2 = new Book();
        book2.setName("springmvc入门测试2");
        book2.setType("JAVA");
        book2.setDesciption("springmvc入门测试结束");

        listBook.add(book1);
        listBook.add(book2);
        return  listBook;
    }


}
